* Improved trimStars()
authorÆvar Arnfjörð Bjarmason <avar@users.mediawiki.org>
Tue, 6 Sep 2005 16:53:58 +0000 (16:53 +0000)
committerÆvar Arnfjörð Bjarmason <avar@users.mediawiki.org>
Tue, 6 Sep 2005 16:53:58 +0000 (16:53 +0000)
* Coding style
* Changed the name of the wfNoMsg() function to wfEmptyMsg()

includes/Licenses.php

index 2f0b1ae..641405f 100644 (file)
@@ -75,19 +75,18 @@ class Licenses {
        
        function trimStars( $str ) {
                $i = $count = 0;
+               $len = strlen( $str );
                
-               wfSuppressWarnings();
-               while ($str[$i++] == '*')
+               while ($len < $i && $str[$i++] == '*')
                        ++$count;
-               wfRestoreWarnings();
-       
+
                return array( $count, ltrim( $str, '* ' ) );
        }
        
        function stackItem( &$list, $path, $item ) {
                $position =& $list;
-               if( $path ) {
-                       foreach( $path as $key ) {
+               if ( $path ) {
+                       foreach ( $path as $key ) {
                                $position =& $position[$key];
                        }
                }
@@ -125,7 +124,7 @@ class Licenses {
        
        function msg( $str ) {
                $out = wfMsg( $str );
-               return wfNoMsg( $str, $out ) ? $str : $out;
+               return wfEmptyMsg( $str, $out ) ? $str : $out;
        }
        
        /**#@-*/